﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Transaction.ascx.cs" Inherits="ERP.Modules.Transaction" %>
<%-------------------------------%>
<ext:Hidden ID="FormatTypeTransaction" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelTransaction">
    <Content>
        <%--------------GridTransaction-----------------%>
        <ext:GridPanel
            ID="grTransaction"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <%-------------StoreTransaction-----------------%>
            <Store>
                <ext:Store
                    ID="StoreTransaction"
                    runat="server"
                    OnReadData="StoreTransaction_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelTransaction" runat="server" IDProperty="Transaction_ID">
                            <Fields>
                                <ext:ModelField Name="Transaction_No" Type="String" />
                                <ext:ModelField Name="Transaction_Name" Type="String" />
                                <ext:ModelField Name="Transaction_Date" Type="Date" />
                                <ext:ModelField Name="Customer_Alias" Type="String" />
                                <ext:ModelField Name="Customer_Name" Type="String" />
                                <ext:ModelField Name="Transaction_Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="30" Align="Center" />
                    <ext:DateColumn ID="Column2" runat="server" Text="Ngày giao dịch" Width="100" DataIndex="Transaction_Date" Format="dd-MM-yyyy"></ext:DateColumn>
                    <ext:Column ID="Column3" runat="server" Text="Số giao dịch" Width="150" DataIndex="Transaction_No"></ext:Column>
                    <ext:Column ID="Column7" runat="server" Text="Mã khách hàng" Width="90" DataIndex="Customer_Alias"></ext:Column>
                    <ext:Column ID="Column8" runat="server" Text="Tên khách hàng" Width="90" DataIndex="Customer_Name"></ext:Column>
                    <ext:Column ID="Column4" runat="server" Text="Ghi chú" Width="100" DataIndex="Transaction_Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <DirectEvents>
                <ItemDblClick OnEvent="TransactionDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Transaction_ID" Value="record.data.Transaction_ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModelTransaction" runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grTransaction}, #{FormatTypeTransaction}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar ID="ToolbarPagging" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbarTransaction" runat="server" StoreID="StoreTransaction" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsTransaction-----------------%>
        <ext:Window ID="WindowsTransaction" runat="server"
            Title="Cập nhật giao dịch"
            DefaultAnchor="100%"
            Width="832px"
            Height="531px"
            Hidden="true"
            AutoScroll="False"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="false"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarTransaction" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelTransaction}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtTransaction_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelTransaction" runat="server"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldContainer ID="FieldContainer1"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtTransaction_No" runat="server" FieldLabel="Mã giao dịch:" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                                <ext:DateField ID="txtTransaction_Date" runat="server" FieldLabel="Ngày giao dịch:" Format="dd/MM/yyyy" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer2"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:Hidden runat="server" ID="txtCustomer_ID"></ext:Hidden>
                                <ext:TextField ID="txtCustomer_Alias" runat="server" FieldLabel="Mã khách hàng:" ReadOnly="True" FieldCls="readonly" Width="222" Margins="0 5 0 0" />
                                <ext:Button runat="server" ID="btnAddCusWindows" ToolTip="Thêm khách hàng" Text="..." Margins="0 20 0 0">
                                    <DirectEvents>
                                        <Click OnEvent="btnCustomer_Click">
                                            <EventMask ShowMask="true" Msg="Đang tải..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:TextField ID="txtCustomer_Name" runat="server" FieldLabel="Tên khách hàng:" ReadOnly="True" FieldCls="readonly" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtCustomer_Address" runat="server" FieldLabel="Địa chỉ:" ReadOnly="True" FieldCls="readonly" Width="250" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer6"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtCustomer_Tax_Code" runat="server" FieldLabel="Mã số thuế:" ReadOnly="True" FieldCls="readonly" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtCustomer_Contact" runat="server" FieldLabel="Liên hệ Ông/Bà:" ReadOnly="True" FieldCls="readonly" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtCustomer_Job" runat="server" FieldLabel="Chức vụ:" ReadOnly="True" FieldCls="readonly" Width="250" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldSet ID="FieldSet2"
                            runat="server"
                            Title="Nội dung giao dịch"
                            Collapsible="true"
                            DefaultAnchor="100%">
                            <Items>
                                <ext:FieldContainer ID="FieldContainer12"
                                    runat="server"
                                    AnchorHorizontal="100%"
                                    Layout="HBoxLayout">
                                    <Items>
                                        <ext:ComboBox runat="server"
                                            ID="cbDestination"
                                            QueryMode="Local"
                                            SelectOnFocus="true"
                                            ForceSelection="True"
                                            FieldLabel="Mục đích" Width="300"
                                            DisplayField="Destination_Name"
                                            ValueField="Destination_ID"
                                            EmptyText="Chọn mục đích"
                                            Margins="0 5 0 0"
                                            AllowBlank="false"
                                            ContextMenuID="cbDestinationContext">
                                            <Store>
                                                <ext:Store runat="server" ID="DestinationStore" OnReadData="ReloadComboBox">
                                                    <Model>
                                                        <ext:Model ID="DestinationModel" runat="server" IDProperty="Destination_ID">
                                                            <Fields>
                                                                <ext:ModelField Name="Destination_Name" Type="String" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:ComboBox>
                                        <ext:Button runat="server" Icon="Add" Margins="0 20 0 0">
                                            <Listeners>
                                                <Click Handler="#{WindowsDestination}.show();"></Click>
                                            </Listeners>
                                            <ToolTips>
                                                <ext:ToolTip runat="server" Html="Thêm mới mục đích" />
                                            </ToolTips>
                                        </ext:Button>
                                        <ext:ComboBox runat="server"
                                            ID="cbMethod"
                                            QueryMode="Local"
                                            SelectOnFocus="true"
                                            ForceSelection="True"
                                            FieldLabel="Phương thức" Width="300"
                                            DisplayField="Method_Name"
                                            ValueField="Method_ID"
                                            EmptyText="Chọn phương thức"
                                            Margins="0 5 0 0"
                                            AllowBlank="false"
                                            ContextMenuID="cbMethodContext">
                                            <Store>
                                                <ext:Store runat="server" ID="MethodStore" OnReadData="ReloadComboBox">
                                                    <Model>
                                                        <ext:Model ID="MethodModel" runat="server" IDProperty="Method_ID">
                                                            <Fields>
                                                                <ext:ModelField Name="Method_Name" Type="String" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:ComboBox>
                                        <ext:Button runat="server" Icon="Add" Margins="0 20 0 0">
                                            <Listeners>
                                                <Click Handler="#{WindowsMethod}.show();"></Click>
                                            </Listeners>
                                            <ToolTips>
                                                <ext:ToolTip runat="server" Html="Thêm mới phương thức" />
                                            </ToolTips>
                                        </ext:Button>
                                    </Items>
                                </ext:FieldContainer>
                                <ext:TextArea ID="txtTransaction_Content" runat="server" FieldLabel="Nội dung" AnchorHorizontal="100%" />
                                <ext:TextArea ID="txtTransaction_Result" runat="server" FieldLabel="Kết quả" AnchorHorizontal="100%" />
                                <ext:TextArea ID="txtTransaction_Note" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" />
                            </Items>
                        </ext:FieldSet>
                        <ext:FieldSet ID="FieldSet1"
                            runat="server"
                            Title="Đánh giá chung"
                            Collapsible="true"
                            DefaultAnchor="100%"
                            Layout="HBoxLayout"
                            MarginSpec="0 0 -5 0">
                            <Items>
                                <ext:CheckboxGroup ID="FieldSet3" runat="server"
                                    Border="false"
                                    Layout="AnchorLayout"
                                    DefaultAnchor="100%"
                                    MarginSpec="0 0 -5 0"
                                    Flex="1"
                                    AllowBlank="False">
                                    <Items>
                                        <ext:FieldSet ID="FieldSet6" runat="server"
                                            Border="false"
                                            Layout="HBoxLayout"
                                            DefaultAnchor="100%"
                                            MarginSpec="0 0 -5 0">
                                            <Items>
                                                <ext:Radio ID="rdbTransaction_Available_Content" runat="server" Width="135px" Name="fav" BoxLabel="Sản phẩm đang dùng" OnDirectCheck="rdbTransaction_Contact_Again_Content_Click">
                                                </ext:Radio>
                                                <ext:TextField ID="txtTransaction_Available_Content" runat="server" Flex="1" AnchorHorizontal="100%" Disabled="True">
                                                </ext:TextField>
                                            </Items>
                                        </ext:FieldSet>
                                        <ext:FieldSet ID="FieldSet7" runat="server"
                                            Border="false"
                                            Layout="HBoxLayout"
                                            DefaultAnchor="100%"
                                            MarginSpec="0 0 -5 0">
                                            <Items>
                                                <ext:Radio ID="rdbTransaction_NotAvailable_Content" runat="server" Width="135px" Name="fav" BoxLabel="Chưa có nhu cầu" OnDirectCheck="rdbTransaction_Contact_Again_Content_Click">
                                                </ext:Radio>
                                                <ext:TextField ID="txtTransaction_NotAvailable_Content" runat="server" Flex="1" AnchorHorizontal="100%" Disabled="True">
                                                </ext:TextField>
                                            </Items>
                                        </ext:FieldSet>
                                        <ext:FieldSet ID="FieldSet8" runat="server"
                                            Border="false"
                                            Layout="HBoxLayout"
                                            DefaultAnchor="100%"
                                            MarginSpec="0 0 -5 0">
                                            <Items>
                                                <ext:Radio ID="rdbTransaction_Contact_Again_Content" runat="server" Width="135px" Name="fav" BoxLabel="Liên hệ lại sau" OnDirectCheck="rdbTransaction_Contact_Again_Content_Click">
                                                </ext:Radio>
                                                <ext:TextField ID="txtTransaction_Contact_Again_Content" runat="server" Flex="1" AnchorHorizontal="100%" Disabled="True">
                                                </ext:TextField>
                                            </Items>
                                        </ext:FieldSet>
                                    </Items>
                                </ext:CheckboxGroup>

                                <ext:Component ID="Component1" runat="server" Width="10" />

                                <ext:CheckboxGroup ID="FieldSet4" runat="server"
                                    Width="250"
                                    Margins="0 0 0 0"
                                    Layout="AnchorLayout"
                                    DefaultAnchor="100%"
                                    MarginSpec="0 0 -5 0"
                                    AllowBlank="False">
                                    <Items>
                                        <ext:Radio ID="rdbTransaction_Potential" runat="server" BoxLabel="Đối tượng có tiềm năng" BoxLabelCls="fav-color" Name="fav-color" />
                                        <ext:Radio ID="rdbTransaction_Unknown" runat="server" BoxLabel="Chưa xác định" Name="fav-color" />
                                        <ext:Radio ID="rdbTransaction_NotPotential" runat="server" BoxLabel="Đối tượng không có tiềm năng" Name="fav-color" />
                                    </Items>
                                </ext:CheckboxGroup>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <%--------------Customer-----------------%>
        <ext:Window ID="WindowTransactionCustomer" runat="server"
            Title="Thông tin khách hàng"
            DefaultAnchor="100%"
            Width="829"
            Height="400"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="False"
            Modal="true"
            Layout="Fit"
            HideMode="Offsets">
            <Content>
                <ext:GridPanel
                    ID="grTransactionCustomer"
                    Border="True"
                    runat="server"
                    AutoWidth="true"
                    AutoScroll="true"
                    Cls="gird"
                    EnableColumnMove="true">
                    <Store>
                        <%--------------StoreTransactionCustomer-----------------%>
                        <ext:Store
                            ID="StoreTransactionCustomer"
                            runat="server"
                            OnReadData="StoreTransactionCustomer_RefreshData"
                            PageSize="10">
                            <Model>
                                <ext:Model ID="Model5" runat="server" IDProperty="Customer_ID">
                                    <Fields>
                                        <ext:ModelField Name="Rows_ID" Type="Int" />
                                        <ext:ModelField Name="Customer_Alias" Type="String" />
                                        <ext:ModelField Name="Customer_Name" Type="String" />
                                        <ext:ModelField Name="Materials_Name" Type="String" />
                                        <ext:ModelField Name="Customer_Phone1" Type="String" />
                                        <ext:ModelField Name="Contact_Email" Type="String" />
                                        <ext:ModelField Name="Customer_Account_Number" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column ID="Column15" runat="server" Text="STT" Width="35" DataIndex="Rows_ID" Locked="True" Align="Center"></ext:Column>
                            <ext:Column ID="Column16" runat="server" Text="ID" Width="15" DataIndex="Customer_ID" Visible="false"></ext:Column>
                            <ext:Column ID="Column17" runat="server" Text="Mã khách hàng" Width="100" DataIndex="Customer_Alias" Locked="True"></ext:Column>
                            <ext:Column ID="Column18" runat="server" Text="Tên khách hàng" Width="200" DataIndex="Customer_Name" Locked="True" Align="Left"></ext:Column>
                            <ext:Column ID="Column25" runat="server" Text="Số điện thoại" Width="100" DataIndex="Customer_Phone1" Align="Right"></ext:Column>
                            <ext:Column ID="Column26" runat="server" Text="Email" Width="200" DataIndex="Contact_Email" Align="Right"></ext:Column>
                            <ext:Column ID="Column27" runat="server" Text="Số tài khoản" Width="100" DataIndex="Customer_Account_Number" Align="Right" Flex="1"></ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CellSelectionModel ID="CellSelectionModel2" runat="server">
                            <DirectEvents>
                                <Select OnEvent="CellTransactionCustomer_Click">
                                    <ExtraParams>
                                        <ext:Parameter Name="Customer_ID" Value="record.data.Customer_ID" Mode="Raw" />
                                    </ExtraParams>
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Select>
                            </DirectEvents>
                        </ext:CellSelectionModel>
                    </SelectionModel>
                    <DockedItems>
                        <ext:Toolbar ID="ToolBarTransactionCustomer" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                            <Items>
                                <ext:TriggerField ID="txtSearchTransactionCustomer" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                                    <Triggers>
                                        <ext:FieldTrigger Icon="Search" />
                                    </Triggers>
                                    <DirectEvents>
                                        <TriggerClick OnEvent="SearchTransactionCustomer_Event"></TriggerClick>
                                        <KeyPress OnEvent="SearchTransactionCustomer_Event"></KeyPress>
                                        <KeyUp OnEvent="SearchTransactionCustomer_Event"></KeyUp>
                                    </DirectEvents>
                                </ext:TriggerField>
                                <ext:PagingToolbar ID="PagingToolbarTransactionCustomer" runat="server" StoreID="StoreTransactionCustomer" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                            </Items>
                        </ext:Toolbar>
                    </DockedItems>
                </ext:GridPanel>
            </Content>
        </ext:Window>
        <ext:Menu runat="server" ID="cbDestinationContext">
            <Items>
                <ext:Button ID="Button4" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbDestination}.clearValue(); #{DestinationStore}.reload(); #{cbDestinationContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <ext:Menu runat="server" ID="cbMethodContext">
            <Items>
                <ext:Button ID="Button2" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbMethod}.clearValue(); #{MethodStore}.reload(); #{cbMethodContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
    </Content>
</ext:Panel>